package demo3;

abstract class Graph1 {
    abstract public void draw();//画图形
    abstract void calcArea();

    public double getArea(){
        return area;
    }
    protected double area;
}

//矩形类
class Rectangle extends Graph1 {
    private double length;
    private double width;
    Rectangle(double length, double width) {
        this.length = length;
        this.width = width;
    }

    public void calcArea(){
        area = length * width;
    }
}

//圆形类
class Cycle extends Graph1 {
    private double r;
    final private static double PI = 3.14;
    public Cycle(double r){
        this.r = r;
}
    public void draw(){
        System.out.println("圆：r = "+r);
    }
    public void calcArea(){
        area = PI * r * r;
    }
}

//三角形类
class Triangle extends Graph1 {
    private double a;
    private double b;
    private double c;

    @Override
    public void draw() {
        System.out.println("三角形：a = " + a + " b = " + b + " c = " + c);
    }
}

public class TestDemo {

}